﻿@model SAIM.Models.ListsViewModel
@{
    var userIdentity = new SAIM.Models.SAIMIdentity(User.Identity);
    ViewBag.Title = "eVirtual";
}
@section css {
@Styles.Render("~/Content/typeahead")
@Styles.Render("~/Content/bootstrap-select")
}

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/typeahead")
@Scripts.Render("~/bundles/bootstrap-select")
<script type="text/javascript">
    urlList = '@Url.Action("_GetList", "EVirtual")';
    item = '@ViewBag.ItemSelected';
    urlUsers = '@Url.Action("GetTypeaheadUsers", "Users")/?id=%QUERY';
</script>
<script type="text/javascript" src="@Url.Content("~/Scripts/EVirtual/Lists.js")"></script>
}

<h2>@SAIM.Resources.Site.CustomLists</h2>
@if(ViewBag.StatusMessage != string.Empty)
{ 
    <div class="alert alert-success fade in">
        <a href="#" class="close close-alert" data-dismiss="alert" aria-label="close">&times;</a>
        @ViewBag.StatusMessage 
    </div>
}
@if (ViewBag.ErrorMessage != string.Empty)
{
    <div class="alert alert-danger fade in">
        <a href="#" class="close close-alert" data-dismiss="alert" aria-label="close">&times;</a>
        @ViewBag.ErrorMessage
    </div>
}

@if ((ViewBag.ValidationErrors != null) && (ViewBag.ValidationErrors != string.Empty))
{
    <div class="panel-group">
        <div class="panel panel-danger">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" href="#collapse1">@SAIM.Resources.Validations.ColumnNotAdded</a>
                </h4>
            </div>
            <div id="collapse1" class="panel-collapse collapse">
                <div class="panel-body">
                    @MvcHtmlString.Create(ViewBag.ValidationErrors.Replace(Environment.NewLine, "<br />"))
                </div>
            </div>
        </div>
    </div>
}
<div class="row">
    <div class="col-md-3">
        <div class="row">
            @using (SAIM.Models.BLL.AspNetUsersBLL user = new SAIM.Models.BLL.AspNetUsersBLL(userIdentity.GetUserId()))
            {
                if (user.isInRole("Create Lists"))
                {
                <div class="col-xs-12">
                    @using (Html.BeginForm("Lists", "EVirtual", FormMethod.Post, new { @role = "form" }))
                    {
                        <div style="padding-top:15px;" class="input-group" >
                            @Html.AntiForgeryToken()
                            <input class="form-control" data-val="true" data-val-required="Nombre de lista obligatorio" id="Id" name="Id" placeholder="Nombre..." type="text">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-default" title="Nueva lista personalizada"><span class="fontelloicon icon-list-alt" aria-hidden="true"></span> <span class="fontelloicon icon-plus-1" aria-hidden="true"></span></button>
                            </span>
                        </div>
                        @Html.ValidationMessageFor(m => m.Id, "", new { @class = "text-danger" })
                    }
                </div>
                }
            }
        </div>
        @if(Model.UserLists.Count > 0)
        { 
            <div class="list-group" style="padding-top:15px;">
                @foreach(var item in Model.UserLists)
                { 
                    <a id="@item.Key" href="#" class="list-group-item custom-list-item" data-id="@item.Key"><div class="text-primary">@item.Value<i class="fontelloicon icon-spin3 animate-spin pull-right hidden"></i></div></a>
                }
            </div>
        }
        else
        {
            <div class="alert alert-warning" style="margin-top:15px;" role="alert" >No se encontraron elementos</div>
        }
    </div>
    <div id="list-panel" class="col-md-9">
        
    </div>
</div>
